package io.renren.modules.work.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.work.entity.ScReportdtlEntity;
import io.renren.modules.work.service.ScReportdtlService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 报销细单
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2022-06-30 09:35:06
 */
@RestController
@RequestMapping("work/screportdtl")
public class ScReportdtlController {
    @Autowired
    private ScReportdtlService scReportdtlService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("work:screportdtl:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = scReportdtlService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{reportdtlid}")
    @RequiresPermissions("work:screportdtl:info")
    public R info(@PathVariable("reportdtlid") String reportdtlid){
		ScReportdtlEntity scReportdtl = scReportdtlService.getById(reportdtlid);

        return R.ok().put("scReportdtl", scReportdtl);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("work:screportdtl:save")
    public R save(@RequestBody ScReportdtlEntity scReportdtl){
		scReportdtlService.save(scReportdtl);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("work:screportdtl:update")
    public R update(@RequestBody ScReportdtlEntity scReportdtl){
		scReportdtlService.updateById(scReportdtl);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("work:screportdtl:delete")
    public R delete(@RequestBody String[] reportdtlids){
		scReportdtlService.removeByIds(Arrays.asList(reportdtlids));

        return R.ok();
    }


    @RequestMapping("/getReportsByNo")
    public R getReportsByNo(@RequestParam("reportno") String reportno){
        return scReportdtlService.getReportsByNo(reportno);
    }





}
